﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <script src="~/Scrips/jquery.js"></script>
    <script type="text/javascript">
        function checkUserName() {
            jQuery.ajax({
                url: "/Default/CheckUserName",
                type: "GET",
                data: { "username": $("#username").val() },
                success: function (data) {
                    if (data == "false") {
                        $("#msg").html("<font color='red'>用户名已存在！</font>");
                    }
                    else {
                        $("#msg").html("<font color='green'>恭喜，用户名可以注册！</font>");
                    }
                },
                error: function (xhr, error, ex) {
                    $("msg").html("出现错误，请稍后再试，带来不便，敬请谅解");
                }
            });
        }
    </script>
</head>
<body>
    <div> 
        <h1>用户名验证</h1>
        用户名：@Html.TextBox("username")<input id="Button1" type="button" value="验证" onclick="checkUserName()"/>
        <span id="msg"></span>
    </div>
</body>
</html>
